package cn.edu.hqu.cst.android.videoplayer;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.MediaController;
import android.widget.VideoView;

public class VideoPlayer extends AppCompatActivity {
    VideoView VideoView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_video_player);
        //新页面接收数据
        Bundle bundle = this.getIntent().getExtras();
        //接收name值
        String a = bundle.getString("a");

        VideoView = findViewById(R.id.VideoView);
        MediaController mController = new MediaController(this);
        VideoView.setVideoPath(String.valueOf(a));
        VideoView.setMediaController(mController);
        mController.setMediaPlayer(VideoView);
        VideoView.requestFocus();

        Button back = findViewById(R.id.back_page);
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent i = new Intent(VideoPlayer.this,VideoSearch.class);
                startActivity(i);
            }
        });
    }
}
